import junit.framework.Assert;
import org.junit.Test;


/**
 * Created by lenovo on 2016/4/12.
 */
public class ComplexNumberTest  {
    @Test
    public void TestFunction1() {
        ComplexNumber complexnumber = new ComplexNumber(3, 5);
        ;
        assert complexnumber.m_dRealPart == 3 : "ComplexNumber(double r,double I)构造函数有错误";
        assert complexnumber.m_dImaginPart == 5 : "ComplexNumber(double r,double I)构造函数有错误";
    }

    @Test
    public void TestFunction2() {
        ComplexNumber complexnumber = new ComplexNumber();

        assert complexnumber.m_dImaginPart == 0 : "ComplexNumber()构造函数有错误";
        assert complexnumber.m_dRealPart == 0 : "ComplexNumber()构造函数有错误";
    }

    @Test
    public void TestSetWay() {
        ComplexNumber complexnumber = new ComplexNumber();

        complexnumber.SetRealPart(1);
        complexnumber.SetImaginaryPart(1);
        assert complexnumber.m_dRealPart == 1 : "SetRealPart方法有错误";
        assert complexnumber.m_dImaginPart == 1 : "SetImaginaryPart方法有错误";
    }

    @Test
    public void TestgetWay() {
        ComplexNumber complexnumber = new ComplexNumber();

        complexnumber.SetRealPart(3);
        complexnumber.SetImaginaryPart(5);
        assert complexnumber.GetRealPart() == 3 : "GetRealPart方法有错误";
        assert complexnumber.GetImaginaryPart() == 5 : "GetImaginaryPart方法有错误";
    }
/*
    @Test
    public void TestStringWay() {
        ComplexNumber complexnumber = new ComplexNumber(3,5);
        System.out.println(complexnumber.toString());
        assertFquals("3.0+5.0i",complexnumber.toString());
    }
*/
    @Test
    public void TestAddWay1() {
        ComplexNumber complexnumber1 = new ComplexNumber(1,1);
        ComplexNumber complexnumber2 = new ComplexNumber(2,2);
        ComplexNumber complexnumber3=complexnumber1.ComplexAdd1(complexnumber2);

        assert complexnumber3.m_dRealPart == 3 : "ComplexAdd方法有错误";
        assert complexnumber3.m_dImaginPart == 3 : "ComplexAdd方法有错误";
    }

    @Test
    public void TestAddWay2() {
        ComplexNumber complexnumber1 = new ComplexNumber(1,1);
        ComplexNumber complexnumber2=complexnumber1.ComplexAdd2(2);

        assert complexnumber2.m_dRealPart == 3 : "ComplexAdd方法有错误";
        assert complexnumber2.m_dImaginPart == 1 : "ComplexAdd方法有错误";
    }

    @Test
    public void TestMinusWay1() {
        ComplexNumber complexnumber1 = new ComplexNumber(1,1);
        ComplexNumber complexnumber2 = new ComplexNumber(2,2);
        ComplexNumber complexnumber3=complexnumber2.ComplexMinus1(complexnumber1);

        assert complexnumber3.m_dRealPart == 1 : "ComplexMinus方法有错误";
        assert complexnumber3.m_dImaginPart == 1 : "ComplexMinus方法有错误";
    }

    @Test
    public void TestMinusWay2() {
        ComplexNumber complexnumber1 = new ComplexNumber(5,1);
        ComplexNumber complexnumber2=complexnumber1.ComplexMinus2(1);

        assert complexnumber2.m_dRealPart == 4 : "ComplexMinus方法有错误";
        assert complexnumber2.m_dImaginPart == 1 : "ComplexMinus方法有错误";
    }

    @Test
    public void TestMultiWay1() {
        ComplexNumber complexnumber1 = new ComplexNumber(3,3);
        ComplexNumber complexnumber2 = new ComplexNumber(3,5);
        ComplexNumber complexnumber3=complexnumber1.ComplexMulti1(complexnumber2);

        assert complexnumber3.m_dRealPart == -6 : "ComplexMinus方法有错误";
        assert complexnumber3.m_dImaginPart == 24 : "ComplexMinus方法有错误";

    }

    @Test
    public void TestMultiWay2() {
        ComplexNumber complexnumber1 = new ComplexNumber(3,3);
        ComplexNumber complexnumber2=complexnumber1.ComplexMulti2(2);

        assert complexnumber2.m_dRealPart == 6 : "ComplexMinus方法有错误";
        assert complexnumber2.m_dImaginPart == 6 : "ComplexMinus方法有错误";

    }

    @Test
    public void TestMultiWay3() {
        ComplexNumber complexnumber1 = new ComplexNumber(3,3);
        ComplexNumber complexnumber2=complexnumber1.ComplexMulti2(2);

        assert complexnumber2.m_dRealPart == 6 : "ComplexMinus方法有错误";
        assert complexnumber2.m_dImaginPart == 6 : "ComplexMinus方法有错误";

    }




}